/*
 * Copyright (C) 2013 The i18nCTS Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.googlecode.i18nCTS.view;

import java.util.Calendar;
import java.util.Locale;

import android.util.Log;

import com.googlecode.i18nCTS.provider.i18nCTSProvider;

public class CalendarSectionFragment extends AbstractSectionFragment {
	private static final String TAG = "I18nCTS_" + CalendarSectionFragment.class.getSimpleName();
	public static final String CATEGORY = "Calendar";

	public CalendarSectionFragment() {
		Log.d(TAG, "ctr");
	}

	@Override
	public String getCategory() {
		return CATEGORY;
	}
	
	@Override
	public void buildList(i18nCTSProvider provider) {
		Calendar calendar;
		
		//GregorianCalendar
		calendar = Calendar.getInstance(Locale.getDefault());
		calendar.set(2012, 12, 5, 0, 0); 
		calendar.add(Calendar.DAY_OF_MONTH, calendar.getFirstDayOfWeek());
		provider.addData(calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault()), 
				"calendar.getFirstDayOfWeek() [" + (String.valueOf(calendar.getFirstDayOfWeek())) + "]");

		// full month names
		String dateutils_month_names = "";
		String dateutils_abbrev_month_names = "";
		
	    for (int i = 0; i < 12; i++) {
	    	calendar.set(Calendar.MONTH, i);
	        dateutils_month_names  += calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()) + " ";
	        dateutils_abbrev_month_names  += calendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.getDefault()) + " ";
	    }
	    provider.addData(dateutils_month_names.trim(), "calendar.getDisplayName (Calendar.MONTH, Calendar.LONG)");
	    provider.addData(dateutils_abbrev_month_names.trim(), "calendar.getDisplayName (Calendar.MONTH, Calendar.LONG)");
	        
	    // Weekday names
		String dateutils_weekday_names = "";
		String dateutils_abbrev_weekday_names = "";
		
		calendar.set(2012, 12, 5, 0, 0); 
		calendar.add(Calendar.DAY_OF_MONTH, calendar.getFirstDayOfWeek());
		for (int i = 0; i < 7; i++) { 
			dateutils_weekday_names += calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault()) + " ";
			dateutils_abbrev_weekday_names += calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault()) + " ";
			calendar.add(Calendar.DAY_OF_MONTH, 1);
		}
		provider.addData(dateutils_weekday_names.trim(), "calendar.getDisplayName (Calendar.DAY_OF_WEEK, Calendar.LONG) ");
		provider.addData(dateutils_abbrev_weekday_names.trim(), "calendar.getDisplayName (Calendar.DAY_OF_WEEK, Calendar.SHORT)");

		provider.addTitle(CATEGORY);
	}
}
